#include<iostream>
using namespace std;
typedef long long LL;
const int N=5100;
int a[N];
int n;
int main()
{
	cin>>n;
	int x=n-1;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	LL ans1=0;
	int cnt=0;
	//cout<<"x=="<<x<<endl; 
	for(int i=1;i<=50000000;i++){
		int z=i;
		int ans=0;
		while(z){
			ans+=z%10;
			z/=10;
		}
		if(ans==x){
			ans1+=i;
			//cout<<"i=="<<i<<endl;
			cnt++;
			if(cnt==n){
				break;
			}
		}
	}
	cout<<ans1<<endl;
	return 0;
} 
